package com.matt.controller.pad;

import com.matt.foundation.model.MemVerificationCache;
import com.matt.commons.model.StatusResponse;
import com.matt.commons.page.PagerQuery;
import com.matt.foundation.vo.roleJob.RoleJobListVo;
import com.matt.service.RoleJobService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static com.matt.foundation.constant.RequestConstant.TICKET;


@RestController
@RequestMapping("/pad/roleJob")
@Slf4j
public class PadRoleJobController {

    @Autowired
    private RoleJobService roleJobService;

    @Autowired
    private MemVerificationCache cache;


    @RequestMapping("/getJobListByRoleCode")
    public StatusResponse getJobListByRoleCode(@RequestHeader(TICKET) String ticket,String roleCode, PagerQuery query){
        Page<RoleJobListVo> recordPage = roleJobService.getJobListByRoleCode(cache.getStaffId(ticket),roleCode, query.getPageNum(), query.getPageSize());
        return StatusResponse.success(recordPage);
    }

    @RequestMapping("/jobFinish")
    public StatusResponse jobFinish(@RequestHeader(TICKET) String ticket, String roleCode, String jobId){
        return StatusResponse.success(roleJobService.jobFinish(cache.getStaffId(ticket), roleCode,jobId));
    }


}
